package com.xiaoshuidi.cloud.module.contract.decotator.instance;


import com.xiaoshuidi.cloud.module.contract.decotator.base.AbstractContractDecotator;
import com.xiaoshuidi.cloud.module.contract.decotator.base.BaseContractDecotator;
import com.xiaoshuidi.cloud.module.contract.decotator.model.BookingConfirmationFilterProcessor;
import com.xiaoshuidi.cloud.module.contract.decotator.model.ElectronicContractProcesson;
import com.xiaoshuidi.cloud.module.contract.decotator.model.PaperContractProcesson;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Auther: zhangyuan
 * @Date: 2023/4/26 14:33
 * @Description: 构建合同创建实例
 * @Version 1.0.0
 */
@Component
public class BuildContractInstance {
    @Resource
    BaseContractDecotator baseContractDecotator;

    @Resource
    BookingConfirmationFilterProcessor bookingConfirmationFilterProcessor;

    @Resource
    ElectronicContractProcesson electronicContractProcesson;

    @Resource
    PaperContractProcesson paperContractProcesson;


    public AbstractContractDecotator buildInstance(){
//        AbstractContractDecotator baseContractDecotator;
//        baseContractDecotator =  new BaseContractDecotator();
//        baseContractDecotator = new ElectronicContractProcesson(baseContractDecotator);
//        baseContractDecotator = new PaperContractProcesson(baseContractDecotator);
//        baseContractDecotator = new BookingConfirmationFilterProcessor(baseContractDecotator);
        bookingConfirmationFilterProcessor.setNextDecotator(paperContractProcesson);
        paperContractProcesson.setNextDecotator(electronicContractProcesson);
        electronicContractProcesson.setNextDecotator(baseContractDecotator);
        return bookingConfirmationFilterProcessor;
    }

    public  AbstractContractDecotator  buildInstanceOther(){
        bookingConfirmationFilterProcessor.setNextDecotator(paperContractProcesson);
        paperContractProcesson.setNextDecotator(baseContractDecotator);
        return bookingConfirmationFilterProcessor;
    }


//    public static void main(String[] args) {
//        BuildContractInstance buildContractInstance = new BuildContractInstance();
//        AbstractContractDecotator abstractContractDecotator = buildContractInstance.buildInstance();
//        abstractContractDecotator.createContract(null);
//    }
}
